package com.zhuss.order.order;

import com.zhuss.bean.bo.order.order.SearchOrderItemBo;
import com.zhuss.enums.OrderStatus;
import com.zhuss.order.db.dao.ext.OrderItemDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhuss.circle.IOrderService;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.processor.OrderRead;

import java.util.Arrays;
import java.util.List;

@Component("orderServiceImpl")
public class OrderServiceImpl implements IOrderService {

	@Autowired
	private OrderRead orderRead;

	@Autowired
	private OrderItemDao orderItemDao;

	@Override
	public Integer countByTrain(Long trainId) throws DzcxException {
		List<Integer> statusList =  Arrays.asList(OrderStatus.未支付.key(), OrderStatus.已提交支付.key(),
				OrderStatus.支付成功.key(),OrderStatus.用户支付中.key(), OrderStatus.已确认上车.key());
		SearchOrderItemBo bo = new SearchOrderItemBo();
		bo.setTrainId(trainId);
		return orderItemDao.countSoldList(bo, statusList);
	}

}
